package net.runman.service;


import net.runman.mapper.TUsersMapper;
import net.runman.model.TUsers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UsersService {

	@Autowired
	private TUsersMapper usersMapper;

	@Transactional(rollbackFor = RuntimeException.class)
	public int addUsers(TUsers users) {
		return usersMapper.insertSelective(users);
	}

	@Cacheable(value = "usersCache", key ="#root.method.name.concat('-').concat(#userId)")
	public TUsers getUsers(Long userId) {
		return usersMapper.selectByPrimaryKey(userId);
	}
}